#if (FEATURE_MODE == 0)
/**
 @file ctc_tmx_srv6.c

 @date 2019-1-1

 @version v6.0

 Define all APIs of SRv6
*/

/****************************************************************************
 *
* Header Files
*
****************************************************************************/
#include "ctc_error.h"

#include "ctc_tmx_srv6.h"
#include "sys_usw_srv6.h"
#include "sys_usw_common.h"
/****************************************************************************
 *
* Defines and Macros
*
*****************************************************************************/

/****************************************************************************
 *
* Global and Declaration
*
*****************************************************************************/
/****************************************************************************
 *
* Function
*
*****************************************************************************/

/**
 @brief Initialize  module
*/
int32
ctc_tmx_srv6_init(uint8 lchip, ctc_srv6_global_cfg_t* p_global_cfg)
{
    uint8 lchip_start = 0;
    uint8 lchip_end = 0;
    ctc_srv6_global_cfg_t global_cfg;

    FEATURE_SUPPORT_CHECK(CTC_FEATURE_SRV6);
    LCHIP_CHECK(lchip);

    if (NULL == p_global_cfg)
    {
        sal_memset(&global_cfg, 0, sizeof(ctc_srv6_global_cfg_t));
        p_global_cfg = &global_cfg;
        global_cfg.sid_format_bmp = 0x1;
    }
    CTC_FOREACH_LCHIP(lchip_start, lchip_end, 1)
    {
        CTC_ERROR_RETURN(sys_usw_srv6_init(lchip, p_global_cfg));
    }

    return CTC_E_NONE;
}

int32
ctc_tmx_srv6_deinit(uint8 lchip)
{
    uint8 lchip_start = 0;
    uint8 lchip_end = 0;

    FEATURE_SUPPORT_CHECK(CTC_FEATURE_SRV6);
    LCHIP_CHECK(lchip);
    CTC_FOREACH_LCHIP(lchip_start, lchip_end, 1)
    {
        CTC_ERROR_RETURN(sys_usw_srv6_deinit(lchip));
    }

    return CTC_E_NONE;
}


int32
ctc_tmx_srv6_add_my_sid(uint8 lchip, ctc_srv6_sid_t* my_sid)
{
    uint8 lchip_start = 0;
    uint8 lchip_end = 0;
    int32 ret                      = CTC_E_NONE;

    FEATURE_SUPPORT_CHECK(CTC_FEATURE_SRV6);
    LCHIP_CHECK(lchip);
    CTC_FOREACH_LCHIP(lchip_start, lchip_end, 1)
    {
        CTC_FOREACH_ERROR_RETURN(CTC_E_NONE,
                                 ret,
                                 sys_usw_srv6_add_my_sid(lchip, my_sid));
    }
    CTC_FOREACH_ROLLBACK(lchip_start, lchip_end)
    {
        sys_usw_srv6_remove_my_sid(lchip, my_sid);
    }

    return ret;
}
int32
ctc_tmx_srv6_remove_my_sid(uint8 lchip, ctc_srv6_sid_t* my_sid)
{
    uint8 lchip_start = 0;
    uint8 lchip_end = 0;
    int32 ret                      = CTC_E_NONE;

    FEATURE_SUPPORT_CHECK(CTC_FEATURE_SRV6);
    LCHIP_CHECK(lchip);
    CTC_FOREACH_LCHIP(lchip_start, lchip_end, 1)
    {
        CTC_FOREACH_ERROR_RETURN(CTC_E_NOT_EXIST,
            ret,
            sys_usw_srv6_remove_my_sid(lchip, my_sid));
    }
    return ret;
}
int32
ctc_tmx_srv6_update_my_sid(uint8 lchip, ctc_srv6_sid_t* my_sid)
{
    uint8 lchip_start = 0;
    uint8 lchip_end = 0;

    FEATURE_SUPPORT_CHECK(CTC_FEATURE_SRV6);
    LCHIP_CHECK(lchip);
    CTC_FOREACH_LCHIP(lchip_start, lchip_end, 1)
    {
        CTC_ERROR_RETURN(sys_usw_srv6_update_my_sid(lchip, my_sid));
    }

    return CTC_E_NONE;
}
#endif
